import {request} from '@/base/Request';
import {DeviceSort} from '@/base/model/DeviceSort';
import qs from 'qs';
import {Device} from '@/base/model/Device';

export function getDeviceSort(params: {
  pageIndex: number,
  pageSize: number,
  sortDirection: string
}) {
  return request.getPage(DeviceSort, '/api/device-sort', {params});
}
export function getDeviceSortV2(params: {
}) {
  return request.get(String, '/api/mall/categoryList', {params});
}

export function postDeviceSort(params: {
  sortName: string,
  sortIcon:string
}) {
  return request.post(DeviceSort, '/api/device-sort', qs.stringify(params));
}

export function getDeviceSortId(
  id: number
) {
  return request.get(DeviceSort, `/api/device-sort/${id}`);
}

export function putDeviceSort(params: {
  id: number,
  sortName: string,
  sortIcon:string
}) {
  return request.put(DeviceSort, '/api/device-sort/{id}'.replace('{id}', params.id.toString()), qs.stringify(params));
}

export function deleteDeviceSort(params: {
  id: number
}) {
  return request.delete('/api/device-sort/{id}'.replace('{id}', params.id.toString()));
}

export function putDeviceSortSort(params: {
  id: []
}) {
  return request.put(DeviceSort, '/api/device-sort/sort', qs.stringify(params, {arrayFormat: 'repeat'}));
}
